// 组合子模块
// 导出一个通用的useStore方法
import React from 'react'
import UserStore from './user.Store'
import ChannelStore from './channel.Store'
import AriticleStore from './article.store'
import SearchStore from './search.Store'
import ArticleDetailStore from './articleDetail.Store'
import CommentStore from './comment.Store'

class RootStore {
  userStore
  channelStore
  articleStore
  searchStore
  articleDetailStore
  commentStore
  constructor() {
    this.userStore = new UserStore()
    this.channelStore = new ChannelStore()
    this.articleStore = new AriticleStore()
    this.searchStore = new SearchStore()
    this.articleDetailStore = new ArticleDetailStore()
    this.commentStore = new CommentStore()
  }
}

// 实例化
export const rootStore = new RootStore()

// react context
const context = React.createContext(rootStore)
// 业务组件统一使用的方法
const useStore = () => React.useContext(context)

export { useStore }
